package basedados;

public class Queries {

	// Stock
	public static final String selectAllStocks = "select * from `mystockdb`.`stock`;";

	public static final String insertStock = "insert into `mystockdb`.`stock` values (?, ?, ?, ?, ?, ?, ?);";
	
	public static final String selectLastStocks = "select * from ( select * from `mystockdb`.`stock`, `mystockdb`.`empresa` WHERE stock.empresa_sigla = empresa.sigla ORDER BY data DESC) as t1 GROUP BY empresa_sigla;";

	public static final String deleteStock = "DELETE FROM `mystockdb`.`stock` WHERE data = ?;";
	
	public static final String[] insertSeveralStocks = {("INSERT INTO `mystockdb`.`stock` (`data`, `variacao`, `cotacao`, `valoraltodia`,`valorbaixodia`, `volume`, `empresa_sigla`) VALUES "), ("(?, ?, ?, ?, ?, ?, ?), "), ("(?, ?, ?, ?, ?, ?, ?);")};

	// Empresa
	public static final String selectAllEmpresas = "select * from `mystockdb`.`empresa`;";
	
	public static final String insertEmpresa = "insert into `mystockdb`.`empresa` values (?, ?);";
	
	public static final String[] insertSeveralEmpresas = {("INSERT INTO `mystockdb`.`empresa` (`sigla`, `nome`) VALUES "), ("(?, ?), "), ("(?, ?);")};
	
	
	// Utilizador
	public static final String selectAllUtilizadores = "select * from `mystockdb`.`utilizador`;";
	
	public static final String selectUtilizador = "select * from `mystockdb`.`utilizador` WHERE email = ?;";
	
	public static final String insertUtilizador = "insert into `mystockdb`.`utilizador` values(?,?,?,?,?,?,?);";
	
	public static final String deleteUtilizador = "delete from `mystockdb`.`utilizador` where email = ?;";
	
	public static final String updateUtilizadorSuperUser = "update `mystockdb`.`utilizador` set superuser = 1 where email = ?;";
	
	public static final String selectTop5Saldo = "SELECT * FROM `mystockdb`.`utilizador` order by saldo DESC limit 5;";
	
	public static final String selectTop5Pontos = "SELECT * FROM `mystockdb`.`utilizador` order by pontos DESC limit 5;";
	
//	SELECT * FROM mystockdb.registo order by valor DESC limit 5;
	
	// Accao
	public static final String selectAccoes = "select * from `mystockdb`.`accao` where utilizador_email = ?;";
	
	// Sugestao
	public static final String insertUtilizadorSugestao = "insert into `mystockdb`.`sugestoes` (utilizador_email) values (?);";
	
	public static final String selectSugestaoFromUtilizador = "SELECT * FROM `mystockdb`.`sugestoes` where utilizador_email = ?;";
	
	//Registo
	public static final String selectAllRegistosFromOneUtilizador = "select * from `mystockdb`.`registo` where utilizador_email = ?;";
}
